<script>
	export default {
		onLaunch: function() {
			const userInfo = uni.getStorageSync('userInfo')
			const autoInfo = uni.getStorageSync('autoSeting') || {}
			if (userInfo) {
				getApp().globalData.userInfo = userInfo
			}
			if (autoInfo.autoLogin) {
				this.getUserInfo()
			}
			
		},
		onShow: function() {
			
		},
		onHide: function() {
			
		},
		globalData: {
			userInfo: {},
			loginStatus: false,
			playInfo: {},
			avatar: ''
		},
		methods: {
			async getUserInfo() {
				const { data: res } = await this.$http({
					url: this.$api.login,
					method: 'POST',
					data: getApp().globalData.userInfo
				})
				if (res.status !== 200) {
					uni.removeStorage({
						key: 'userInfo',
						success() {
							console.log('登录失败，清除账号缓存')
						}
					})
					return 
				}
				if (!res.data.user_status) {
					return 
				}
				getApp().globalData.loginStatus = true
				getApp().globalData.userInfo = res.data
			}
		}
	}
</script>

<style>
	
	
	// #ifndef APP-PLUS-NVUE
	@import url("@/static/css/iconfont.css");
	@import './commons/uni.css';
	/*每个页面公共css */
	
	uni-page-body, #app, page, body {height: 100%;}
	// #endif
</style>
